/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.yunhoo.fee.db.impl;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.yunhoo.fee.model.DangHui;
import com.yunhoo.sys.db.util.IbatisTemplate;
import com.yunhoo.sys.util.common.LoginParam;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Administrator
 */
public class DangHuiImpl {

    private static final String NAME_SPACE = "testconct.";

    public static List<DangHui> getDetailList(Map map) {
        map.put("orgCode", LoginParam.getOrg().getCode());
        return IbatisTemplate.queryForList(NAME_SPACE + "getDetailList", map);
    }

    public static List<DangHui> getDetail(Map map) {
        return IbatisTemplate.queryForList(NAME_SPACE + "getDetail", map);
    }

    public static List<DangHui> selectFeeList(Map map) {
        return IbatisTemplate.queryForList(NAME_SPACE + "selectFeeList", map);
    }

    public static void insertDangHui(DangHui dang) {
        IbatisTemplate.insert(NAME_SPACE + "insertDangHui", dang);
    }

    public static void deleteByIyear(Map map) {
        IbatisTemplate.delete(NAME_SPACE + "deleteByIyear", map);
    }

    public static List<DangHui> calHuifei(Map map) {
        return IbatisTemplate.queryForList(NAME_SPACE + "calHuifei", map);
    }

    public static List<DangHui> calDangfei(Map map) {
        return IbatisTemplate.queryForList(NAME_SPACE + "calDangfei", map);
    }
//批量处理

    public static void insert(List<DangHui> list) {
        System.out.println(NAME_SPACE + "insertDangHui list");
        try {
            SqlMapClient sqlMap = IbatisTemplate.getSqlMapClient();
            sqlMap.startTransaction();
            sqlMap.startBatch();
            for (DangHui li : list) {
                sqlMap.update(NAME_SPACE + "insertDangHui", li);
            }
            sqlMap.executeBatch();
            sqlMap.commitTransaction();
        } catch (SQLException ex) {
            Logger.getLogger(DangHuiImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public static void update_huifei(List<DangHui> dangli) {
        System.out.println("save dangHui list huifei!");
        try {
            SqlMapClient sqlMap = IbatisTemplate.getSqlMapClient();
            sqlMap.startTransaction();
            sqlMap.startBatch();
            for (DangHui l : dangli) {
                //sqlMap.update(NAME_SPACE + "updatedangfei", l);
                sqlMap.update(NAME_SPACE + "update_huifei", l);
            }
            sqlMap.executeBatch();
            sqlMap.commitTransaction();
        } catch (SQLException ex) {
            Logger.getLogger(DangHuiImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public static void update_dangfei(List<DangHui> dangli) {
        System.out.println("save dangHui list dangfei!");
        try {
            SqlMapClient sqlMap = IbatisTemplate.getSqlMapClient();
            sqlMap.startTransaction();
            sqlMap.startBatch();
            for (DangHui l : dangli) {
                //sqlMap.update(NAME_SPACE + "updatedangfei", l);
                sqlMap.update(NAME_SPACE + "update_dangfei", l);
            }
            sqlMap.executeBatch();
            sqlMap.commitTransaction();
        } catch (SQLException ex) {
            Logger.getLogger(DangHuiImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public static List<DangHui> getTotal(Map map) {
        return IbatisTemplate.queryForList(NAME_SPACE + "getDanghuiTotal", map);
    }

    public static List<DangHui> getimonthTotal(Map map) {
        return IbatisTemplate.queryForList(NAME_SPACE + "getimonthTotal", map);
    }

    public static List<DangHui> getdanghuiDetail(Map map) {
        return IbatisTemplate.queryForList(NAME_SPACE + "getdanghuiDetail", map);
    }

    public static List<DangHui> getimonthAllTotal(Map map) {
        return IbatisTemplate.queryForList(NAME_SPACE + "getimonthAllTotal", map);
    }

    public static List<DangHui> queryAllDetailli(Map map) {
        map.put("orgCode",LoginParam.getOrg().getCode());
        return IbatisTemplate.queryForList(NAME_SPACE + "queryAllDetailli", map);
    }

    public static void main(String args[]) {
        DangHui l = new DangHui();
        l.setDangfei(0.2);
        l.setCpsn_number("01009");
        IbatisTemplate.update("updatedangfei", l);
    }
}
